package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-07-25
 * Time: 16:59
 */
public class TestDemo {

    //先执行t1  t1执行完在执行 t2

    public static void main(String[] args) throws InterruptedException {
        System.out.println("main 开始");
        Thread t1 = new Thread(()->{
            System.out.println("t1 beign");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t1 end");
        });


        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Thread t2 = new Thread(()->{
            System.out.println("t2 beign");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t2 end");
        });

        t2.start();
        try {
            t2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Thread.sleep(1000);

        System.out.println("main  结束");
    }

}
